package com.qianbao.qianbaobusiness.json;

import android.support.annotation.Keep;
import android.text.TextUtils;

import com.baseandroid.config.Global;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Keep
public class ShopListInfo implements Serializable {
    private static final long serialVersionUID = -7249210890121608669L;
    public List<MerchantInfo> merchantList = new ArrayList<>();
    public LoanInfo loanInfo;

    public MerchantInfo getLoanMerchantInfo() {
        if (merchantList == null || merchantList.size() == 0 || loanInfo == null || TextUtils
                .isEmpty(loanInfo.getMerchantCode())) {
            return null;
        } else {
            String merchantCode = loanInfo.getMerchantCode();
            for (MerchantInfo merchantInfo : merchantList) {
                if (merchantInfo.merchantNo.equals(merchantCode)) {
                    return merchantInfo;
                }
            }
            return null;
        }
    }

    public class LoanInfo implements Serializable {
        private static final long serialVersionUID = -4374938728106748581L;
        private boolean enable;

        private String amount;
        private String merchantCode;
        private String desc;
        private String msg;
        public boolean enableReturn;

        public boolean isEnable() {
            return enable;
        }

        public void setEnable(boolean enable) {
            this.enable = enable;
        }

        public String getAmount() {
            return amount;
        }

        public void setAmount(String amount) {
            this.amount = amount;
        }

        public String getMerchantCode() {
            return merchantCode;
        }

        public void setMerchantCode(String merchantCode) {
            this.merchantCode = merchantCode;
        }

        public String getDesc() {
            return desc;
        }

        public void setDesc(String desc) {
            this.desc = desc;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }
    }

    public static MerchantInfo getMerchant(String merchantNo){
        for(int i = 0; i < Global.getShopListInfo().merchantList.size() ; i++){
            if(Global.getShopListInfo().merchantList.get(i).merchantNo.equals(merchantNo) ){
                return Global.getShopListInfo().merchantList.get(i);
            }
        }
        return null;
    }
}

